package com.warehouse.controller;

import com.warehouse.dto.ReportWarin;
import com.warehouse.dto.Result;
import com.warehouse.dto.ResultCode;
import com.warehouse.dto.Surplus;
import com.warehouse.service.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 报表管理后台
 */
@Api(tags = "报表管理")
@RestController
@RequestMapping("/api/report")
public class ReportController {

    //注入报表管理业务层
    @Autowired
    private ReportService reportService;

    /**
     * 库存清单
     */
    @ApiOperation(value = "库存清单",httpMethod = "GET")
    @RequestMapping(value = "/",method = RequestMethod.GET)
    public Result selectSurp(){
        List<Surplus> list=reportService.findWare();
        return new Result(ResultCode.SUCCESS,list);
    }
    /**
     * 可出库存
     */
    @ApiOperation(value = "可出库存",httpMethod = "GET")
    @RequestMapping(value = "/surp",method = RequestMethod.GET)
    public Result selectReport(){
        List<Surplus> list=reportService.selectSurp();
        return new Result(ResultCode.SUCCESS,list);
    }

    /**
     * 库存预警 :d
     *
     *
     */
    @ApiOperation(value = "库存预警",httpMethod = "GET")
    @RequestMapping(value = "/wareWarin",method = RequestMethod.GET)
    public Result findware(){
        List<ReportWarin> list=reportService.findProNum();
        if(list!=null){
            return new Result(ResultCode.SUCCESS,list);
        }
        Result result=new Result();
        result.setMessage("没有此商品");
        return result;
    }
    /**
     * 库存预警的模糊搜索
     */
    @ApiOperation(value = "库存预警的模糊搜索,根据商品的名称",httpMethod = "GET")
    @RequestMapping(value = "/warinLike{proName}",method = RequestMethod.GET)
    public Result findLikePro(@PathVariable("proName") String proName){
        List<ReportWarin> list= reportService.findLikePro(proName);
        if(list!=null){
            return new Result(ResultCode.SUCCESS,list);
        }
        Result result=new Result();
        result.setMessage("没有此商品");
        return result;
    }
    /***
     *库存台账
     */
    @ApiOperation(value = "库存台账",httpMethod = "GET")
    @RequestMapping(value = "/money",method = RequestMethod.GET)
    public Result inWareMoney(){
        return null;
    }

    /**
     * 库存容量 capacity
     */
    @ApiOperation(value = "库存容量",httpMethod = "GET")
    @RequestMapping(value = "/capacity",method = RequestMethod.GET)
    public Result findWareArea(){
        List<Surplus> list= reportService.findWareArea();
        return new Result(ResultCode.SUCCESS,list);
    }
}
